package com.intellij.GraphEditor;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseListener;

/**
 * Created by IntelliJ IDEA.
 * User: karpov
 * Date: 29.11.2006
 * Time: 23:52:43
 * To change this template use File | Settings | File Templates.
 */
public class MyJMenu {
    JMenuBar menuBar;
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    JPopupMenu popup;

    public MyJMenu(Editor object) {
     //   Editor editor=object;

        menuBar = new JMenuBar();
        menu = new JMenu("File");
        menu.setMnemonic(KeyEvent.VK_F);
        menuBar.add(menu);
        menuItem = new JMenuItem("Open...",KeyEvent.VK_O);
        menu.add(menuItem);
        menuItem = new JMenuItem("Save...",KeyEvent.VK_S);
        menu.add(menuItem);
        menuItem = new JMenuItem("Save as",KeyEvent.VK_A);
        menu.add(menuItem);
        menuItem = new JMenuItem("Exit",KeyEvent.VK_X);
        menu.add(menuItem);
        menu = new JMenu("Edit");
        menu.setMnemonic(KeyEvent.VK_E);
        menuBar.add(menu);
        menuItem = new JMenuItem("Node",KeyEvent.VK_N);
        menu.add(menuItem);
        menuItem = new JMenuItem("Edge");
        menuItem.setMnemonic(KeyEvent.VK_E);        
        menu.add(menuItem);
        menu = new JMenu("View");
        menu.setMnemonic(KeyEvent.VK_V);
        menuBar.add(menu);

        submenu = new JMenu("Toolbars");
        submenu.setMnemonic(KeyEvent.VK_T);

        menuItem = new JMenuItem("Main ToolBar");
        submenu.add(menuItem);

        menuItem = new JMenuItem("Work ToolBar");
        submenu.add(menuItem);
        menu.add(submenu);

        menuItem = new JMenuItem("Grid",KeyEvent.VK_E);
        menu.add(menuItem);

        menu = new JMenu("Order actions");
        menu.setMnemonic(KeyEvent.VK_O);
        menuBar.add(menu);
        menuItem = new JMenuItem("Action 1",KeyEvent.VK_1);
        menu.add(menuItem);
        menuItem = new JMenuItem("Action 2",KeyEvent.VK_2);
        menu.add(menuItem);
        menu = new JMenu("Help");
        menu.setMnemonic(KeyEvent.VK_H);
        menuBar.add(menu);
        menuItem = new JMenuItem("Help topics",KeyEvent.VK_T);
        menu.add(menuItem);
        menuItem = new JMenuItem("About",KeyEvent.VK_A);
        menu.add(menuItem);




    //...where the GUI is constructed:
    //Create the popup menu.
    popup = new JPopupMenu();
    menuItem = new JMenuItem("A popup menu item");
  //  menuItem.addActionListener(this);
    popup.add(menuItem);
    menuItem = new JMenuItem("Another popup menu item");
    popup.add(menuItem);

    //Add listener to components that can bring up popup menus.
    MouseListener popupListener = new PopupListener(popup);
    object.output.addMouseListener(popupListener);
 //   menuBar.addMouseListener(popupListener);
    }
}
